home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 43 / Amiga Format CD43 (1999)(Future Publishing)(GB)(Track 1 of 2)[!][issue 1999-09].iso / -serious- / programming / other / hunk / rexx / shortrelocs.rexx < prev    next >
OS/2 REXX Batch file  |  1999-06-14  |  1KB  |  54 lines

  1. /* Compact a binary by changing all reloc entries to short.
  2.    © 1998 THOR Software.*/
  3.  
  4. PARSE ARG binary .
  5. if binary='?' | binary='' then; do
  6.     say 'Usage: ShortRelocs.rexx <binary>,'
  7.     say 'where <binary> is the FULL path of an object module.'
  8.     exit 0
  9. end
  10. if ~exists(binary) then; do
  11.     say 'I can'D2C(39)'t find the file "'binary'", please check!'
  12.     exit 10
  13. end
  14. if ~show(P,'HUNK.1') then; do
  15.     if ~open(.hunklocation,'ENV:Hunk','R') then; do
  16.         address command 'RequestFile Drawer="SYS:" NoIcons Title="Please locate the Hunk" >ENV:Hunk'
  17.         if ~open(.hunklocation,'ENV:Hunk','R') then; exit
  18.         address command 'Copy ENV:Hunk to ENVARC:Hunk'
  19.     end    
  20.     wherehunk=readln(.hunklocation)
  21.     close(.hunklocation)
  22.     if wherehunk='' then; do
  23.         address command 'Delete >NIL: ENV:Hunk ENVARC:Hunk'
  24.         exit
  25.     end
  26.     wherehunk=substr(wherehunk,2,length(wherehunk)-2)
  27.     snip=max(lastpos(':', wherehunk),lastpos('/', wherehunk)) +1
  28.     filename=substr(wherehunk,snip)
  29.     pathname=strip(left(wherehunk, snip-1),'T', '/')
  30.     pragma('D',pathname)
  31.     address command 'run' filename
  32. end
  33. do i=1 while ~show(P,'HUNK.1') & (i<10)
  34.     address command 'Wait 1'
  35. end
  36. if i>9 then; do
  37.     say "Can't lauch the Hunk processor."
  38.     say "Delete ENV:Hunk, ENVARC:Hunk and try again."
  39.     exit
  40. end
  41. address 'HUNK.1'
  42. LOCKGUI
  43. VERIFY off
  44. OPEN binary
  45. WRITE32SHORT on
  46. COUNT 'hunks'
  47. do i=0 to hunks-1
  48.     StripZeros i
  49. end
  50. SAVE binary
  51. VERIFY on
  52. UNLOCKGUI
  53. WINDOWTOBACK    
  54.